package com.mycookbook;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class MainActivity extends Activity
{
	private ImageButton buttonAppetizer;
	private ImageButton buttonMainCourse;
	private ImageButton buttonDessert;
	private ImageButton buttonAllRecipe;
	
	DatabaseHandler db;
	
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainlayout);
        
        //get database from application context
        ApplicationData d = ((ApplicationData)getApplicationContext());
        
        db = d.GetDatabase();
        
        //add some data 
        db.addRecipe(new Recipe("shrimpCocktail5","Appetizer","mix egg and bacon;throw some salt on","egg;salt;bacon",""));
        db.addRecipe(new Recipe("IceCream5","Dessert","fry bacon;stir eggs and salt","egg;salt;bacon",""));   
        db.addRecipe(new Recipe("Pasta Boulognese5","Main Course","put eggs, salt  and bacon in a pot; stir lightly","egg;salt;bacon",""));  
        
        buttonAppetizer = (ImageButton)findViewById(R.id.button_appetizer);       
        buttonMainCourse = (ImageButton)findViewById(R.id.button_mainCourse); 
        buttonDessert = (ImageButton)findViewById(R.id.button_dessert);
        buttonAllRecipe = (ImageButton)findViewById(R.id.button_allrecipe);
    }
    
    public void onClickAppetizer(View v)
    {
    	Switch("Appetizer");
    }
    
	public void onClickMainCourse(View v)
	{
		Switch("Main Course");
	}
    
	public void onClickDessert(View v)
	{
		Switch("Dessert");
	}
	
	public void onClickAllRecipe(View v)
	{
		Switch("All Recipe");
	}
	
	private void Switch(String input)
	{
    	Intent intent = new Intent();
    	intent.putExtra("category", input);
    	intent.setClass(this, CategoryActivity.class);
    	startActivity(intent);
	}
}
